﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace KABS_Commander
{
    public partial class KABS_Commander : Form
    {
        private bool inComplex = true;
        private int movieSpeed = 1;

        private void expandMessageBox()
        {
            int expandWidth = groupBox_cmdArea.Width + groupBox_cmdArea.Margin.Left;
            for (int i = 0; i < movieSpeed; i++)
                groupBox_msg.Width += expandWidth/movieSpeed;
        }

        private void shrinkMessageBox()
        {
            int expandWidth = groupBox_cmdArea.Width + groupBox_cmdArea.Margin.Left;
            for (int i = 0; i < movieSpeed; i++)
                groupBox_msg.Width -= expandWidth / movieSpeed;
        }

        private void expandForm()
        {
            int expandWidth = groupBox_cmdCvt.Width;
            this.MaximumSize = new System.Drawing.Size();
            this.MinimumSize = new System.Drawing.Size();
            for (int i = 0; i < movieSpeed; i++)
                this.Size = new System.Drawing.Size(this.Size.Width + expandWidth / movieSpeed, this.Size.Height);
            this.MaximumSize = this.Size;
            this.MinimumSize = this.Size;
        }

        private void shrinkForm()
        {
            int expandWidth = groupBox_cmdCvt.Width;
            this.MaximumSize = new System.Drawing.Size();
            this.MinimumSize = new System.Drawing.Size();
            for (int i = 0; i < movieSpeed; i++)
                this.Size = new System.Drawing.Size(this.Size.Width - expandWidth/movieSpeed, this.Size.Height);
            this.MaximumSize = this.Size;
            this.MinimumSize = this.Size;
        }

        private void transformToolStripMenuItem_Click(object sender, EventArgs e)
        {
            inComplex = !inComplex;
            groupBox_cmdArea.Visible = inComplex;
            groupBox_cmdCvt.Visible = inComplex;
            groupBox_tcpInfo.Visible = inComplex;
            if (inComplex) // from simple -> complex
            {
                expandForm();
                shrinkMessageBox();
                notifyIcon_commander.BalloonTipText = "More functions, more duty.";
                notifyIcon_commander.ShowBalloonTip(100);
            }
            else // from complex -> simple
            {
                shrinkForm();
                expandMessageBox();
                notifyIcon_commander.BalloonTipText = "Keep It Simple, Superman.";
                notifyIcon_commander.ShowBalloonTip(100);
            }
        }
    }
}
